package rc.work.module.infra.dal.mysql.onlyoffice.filetable;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import rc.work.framework.common.pojo.PageResult;
import rc.work.framework.mybatis.core.mapper.BaseMapperX;
import rc.work.framework.mybatis.core.query.LambdaQueryWrapperX;

import rc.work.module.infra.controller.admin.onlyoffice.filetable.vo.FileTablePageReqVO;
import rc.work.module.infra.controller.admin.onlyoffice.vo.FileInfoDo;
import rc.work.module.infra.dal.dataobject.file.FileDO;

import java.util.List;

/**
 * 文件绑定表信息 Mapper
 *
 * @author 默认
 */
@Mapper
public interface FileTableMapper extends BaseMapperX<FileDO> {

    default PageResult<FileDO> selectPage(FileTablePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FileDO>()
//                .eqIfPresent(FileDO::getTableName, reqVO.getTableName())
//                .eqIfPresent(FileDO::getTableId, reqVO.getTableId())
//                .eqIfPresent(FileDO::getBelongdept,reqVO.getBelongdept())
                .likeIfPresent(FileDO::getName, reqVO.getName())
                .orderByDesc(FileDO::getId));
    }

    FileInfoDo getFileInfoDo(@Param("fileId") Long fileId);

    void updateFileInfoDo(@Param("fileTableDO")FileInfoDo fileTableDO);

    void deleteFileTableByTableIdAndTableName(@Param("tableId")Long tableId, @Param("tableName")String tableName);

    List<FileDO> getFileTableAll();

    List<FileDO> getFileTable(@Param("tableId")Long tableId, @Param("tableName")String tableName);

    void deleteFileTableByIdNameType(@Param("tableId")Long tableId, @Param("tableName")String tableName,@Param("tableType") String tableType);
}